package com.medicine.hbp.ui;

import org.kymjs.kjframe.http.HttpParams;
import org.kymjs.kjframe.ui.BindView;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.medicine.hbp.R;
import com.medicine.hbp.base.BaseActivity;
import com.medicine.hbp.http.AppHttpCallBack;
import com.medicine.hbp.http.AppHttps;
import com.medicine.hbp.http.HttpInterface;
import com.medicine.hbp.mob.findIntegralActivityListVo;
import com.medicine.hbp.uitl.ToastUtil;
/**
 * 提现界面
 * @author Administrator
 *
 */
public class WithdrawDepositActivity  extends BaseActivity {
	@BindView(id = R.id.btn_tx, click = true)
	public Button btn_tx;

	@BindView(id = R.id.edit_zfb)
	public EditText edit_zfb;
	@BindView(id = R.id.edit_zfbname)
	public EditText edit_zfbname;
	@BindView(id = R.id.edit_num)
	public EditText edit_num;

	@Override
	public void setRootView() {
		super.setRootView();
		setContentView(R.layout.activity_withdrawdeposit);
	}

	@Override
	public void initWidget() {
		super.initWidget();
		initTop() ;
	}
	private void initTop() {
		TopView topview = (TopView) findViewById(R.id.topview);
		topview.setTitle("提现");
		topview.setLeftVisibility(View.GONE);
		topview.setLeftVisibilityExit(View.VISIBLE);
		topview.setRightVisibility(View.INVISIBLE);
		topview.setLeftOnClickExit(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
	}
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
			case R.id.btn_tx:
				String name=edit_zfbname.getText().toString();
				if(TextUtils.isEmpty(name)){
					ToastUtil.showShort(aty, "请输入支付宝用户姓名");
					return;
				}
				String zfb=edit_zfb.getText().toString();
				if(TextUtils.isEmpty(zfb)){
					ToastUtil.showShort(aty, "请输入支付宝账号");
					return;
				}
				String num=edit_num.getText().toString();
				if(TextUtils.isEmpty(num)){
					ToastUtil.showShort(aty, "请输入提现金额");
					return;
				}
				http(num,zfb,name);
				break;
		}
	}
	/**
	 * 用户申请提现接口
	 */
	private void http(String price,String zfbAccount,String name) {
		HttpParams params = new HttpParams();
		params.put("price", price);//提现金额
		params.put("zfbAccount", zfbAccount);//支付宝账户
		params.put("zfbName", name);//支付宝姓名
		AppHttps.HttpPost(aty, HttpInterface.GET_WITH_DRAWAL, params,
				new AppHttpCallBack<findIntegralActivityListVo>(findIntegralActivityListVo.class, aty) {
					@Override
					public void onSuccess(findIntegralActivityListVo result) {
					}
					@Override
					public void onFailures(int errorCode, String errorMsg) {
						ToastUtil.showShort(aty, errorMsg);
					}
				});

	}
}
